﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AirLinq.Providers.Sql {
	public class SqlSubqueryComparision : SqlPredicate{
		private readonly SqlExpression _test;
		private readonly SqlNodeType _nodeType;
		private readonly bool _forAll;
		private readonly SqlQueryExpressionBase _subQuery;
		public SqlSubqueryComparision(SqlExpression test, SqlNodeType nodeType, bool forAll, SqlQueryExpressionBase subquery) {
			if (test == null) {
				throw new ArgumentNullException("test");
			}
			if (nodeType != SqlNodeType.EQ
				&& nodeType != SqlNodeType.NotEQ
				&& nodeType != SqlNodeType.GT
				&& nodeType != SqlNodeType.GE
				&& nodeType != SqlNodeType.LT
				&& nodeType != SqlNodeType.LE) {
				throw new ArgumentException("operation must be logical operation");
			}
			if (subquery == null) {
				throw new ArgumentNullException("subquery");
			}
			_test = test;
			_nodeType = nodeType;
			_forAll = forAll;
			_subQuery = subquery;
		}
		public SqlExpression Test {
			get {
				return _test;
			}
		}
		public override SqlNodeType NodeType {
			get {
				return _nodeType;
			}
		}
		public bool ForAll {
			get {
				return _forAll;
			}
		}
		public SqlQueryExpressionBase SubQuery {
			get {
				return _subQuery;
			}
		}
		public override bool IsNotInjectionable {
			get {
				return false;
			}
		}
	}
}
